'''
main.py

Main file for 2 Pints
2 Pints is an implementation of Quarto written in Python

Dave Schwantes
2010
www.dinosaurseateverybody.com
'''

from QuartoGame import *
from TwoPints import *

def main():
    print "2 Pints"
    print "a Quarto playing bot by Dave Schwantes"
    print ""
    game = QuartoGame()
    bot = TwoPints()
    
    print "The Board:"
    game.displayBoard()
    print ""
        
    while not game.isGameOver():
        
        if game.turn == 0:
            print "2 Pints Bot selecting piece..."
            bot.selectPiece(game)
            print "Piece selected."
        else:
            print "Available Pieces:"
            game.displayAvailablePieces()
            print ""
            print "Player %i select a piece:" % (game.turn)
            selected_piece = input()
            game.selectPiece(selected_piece)
        
        game.nextTurn()
        
        print "Selected Piece:"
        game.selectedPiece.displayPiece()
        
        if game.turn == 0:
            print "2 Pints Bot placing piece on board..."
            bot.placePiece(game)
            print "Piece placed on board."
        else:
            print "Player %i select x for piece:" % (game.turn)
            x = input()
            print "Player %i select y for piece:" % (game.turn)
            y = input()
            
            game.placePiece(x,y)
        
        game.displayBoard()
        print ""        
        
    print "Game Over"
    print "Winner: player %i" % (game.turn)
        

if __name__ == '__main__':
    main()